home *** CD-ROM | disk | FTP | other *** search
/ Champak 145 / (Vol 145) Dec 21 2011.iso / Games / kupidon-strike.swf / scripts / frame_168 / DoAction.as
Encoding:
Text File  |  2011-12-21  |  9.8 KB  |  384 lines

  1. function do_sound(snd, flag)
  2. {
  3.    boomSound.attachSound(snd);
  4.    boomSound.start();
  5. }
  6. function bullet_rem()
  7. {
  8.    bullet._x = 100000;
  9. }
  10. function bob(x, y)
  11. {
  12.    _root.boom_dp = _root.boom_dp + 1;
  13.    if(boom_db >= 300)
  14.    {
  15.       boom_db = 200;
  16.    }
  17.    nm = "bob" + boom_dp;
  18.    _root.tohit.push(nm);
  19.    do
  20.    {
  21.       vx = random(20) - 10;
  22.       vy = random(20) - 10;
  23.    }
  24.    while(vx <= 2 && vx >= -2 && vy <= 2 && vy >= -2);
  25.    
  26.    _root.attachMovie("bob_obj",nm,boom_dp,{vectorX:vx,vectorY:vy});
  27.    _root[nm]._x = x + _root.half_heart;
  28.    _root[nm]._y = y + _root.half_heart + 5;
  29.    _root[nm].cacheAsBitmap();
  30.    _root[nm].active = true;
  31.    _root.torem_objects.push(nm);
  32. }
  33. function bobo(x, y)
  34. {
  35.    _root.boom_dp = _root.boom_dp + 1;
  36.    if(boom_db >= 300)
  37.    {
  38.       boom_db = 200;
  39.    }
  40.    nm = "bobo" + boom_dp;
  41.    _root.tohit.push(nm);
  42.    _root.attachMovie("bobo_obj",nm,boom_dp);
  43.    _root[nm]._x = x + _root.half_heart;
  44.    _root[nm]._y = y + _root.half_heart + 5;
  45.    _root[nm].cacheAsBitmap();
  46.    _root[nm].active = true;
  47.    _root.torem_objects.push(nm);
  48. }
  49. function spark(x1, y1, x2, y2)
  50. {
  51.    _root.boom_dp = _root.boom_dp + 1;
  52.    if(boom_db >= 300)
  53.    {
  54.       boom_db = 200;
  55.    }
  56.    nm = "spark_" + boom_dp;
  57.    _root.attachMovie("spark_obj",nm,boom_dp);
  58.    _root.torem_objects.push(nm);
  59.    dx = x1 - x2;
  60.    dy = y1 - y2;
  61.    path = Math.sqrt(dx * dx + dy * dy);
  62.    di = 12;
  63.    dj = 3;
  64.    path_part = path / di;
  65.    _root[nm].draw_obj.moveTo(x1,y1);
  66.    j = 0;
  67.    while(j < dj)
  68.    {
  69.       i = 1;
  70.       while(i <= di)
  71.       {
  72.          delta_x = x1 - x2;
  73.          delta_y = y1 - y2;
  74.          a = (- Math.atan2(delta_x,delta_y)) / 0.017453292519943295;
  75.          if(i + 1 < di)
  76.          {
  77.             a += -2 + random(4);
  78.          }
  79.          _root[nm].draw_obj.lineStyle(1,39423,100,true,"none","round","miter",1);
  80.          _root[nm].draw_obj.lineTo(x1 + path_part * i * Math.sin(a * 0.017453292519943295),y1 - path_part * i * Math.cos(a * 0.017453292519943295));
  81.          i++;
  82.       }
  83.       j++;
  84.    }
  85. }
  86. function boom(x, y, clr, size)
  87. {
  88.    _root.boom_dp = _root.boom_dp + 1;
  89.    if(boom_db >= 300)
  90.    {
  91.       boom_db = 200;
  92.    }
  93.    nm = "boom" + boom_dp;
  94.    _root.torem_objects.push(nm);
  95.    _root.attachMovie("boom_obj",nm,boom_dp);
  96.    _root[nm]._x = x + _root.half_heart;
  97.    _root[nm]._y = y + _root.half_heart;
  98.    if(size != undefined)
  99.    {
  100.       _root[nm]._width = size;
  101.       _root[nm]._height = size;
  102.    }
  103.    _root[nm].boom_ani.gotoAndStop(clr);
  104.    _root[nm].cacheAsBitmap();
  105. }
  106. function try_end()
  107. {
  108.    if(_root.tohit.length <= 0)
  109.    {
  110.       if(level_arrows <= 0)
  111.       {
  112.          if(hearts_beat >= hearts_req)
  113.          {
  114.             win();
  115.             return true;
  116.          }
  117.          if(hearts_beat <= hearts_req)
  118.          {
  119.             lose();
  120.             return true;
  121.          }
  122.       }
  123.       if(hearts_beat >= _root.level_objects.length)
  124.       {
  125.          win();
  126.          return true;
  127.       }
  128.    }
  129.    return false;
  130. }
  131. function show_blur()
  132. {
  133.    myBitmapData.draw(_root);
  134.    var _loc5_ = 5;
  135.    var _loc4_ = 5;
  136.    var _loc2_ = 3;
  137.    var _loc3_ = new flash.filters.BlurFilter(_loc5_,_loc4_,_loc2_);
  138.    myBitmapData.applyFilter(myBitmapData,myBitmapData.rectangle,new flash.geom.Point(0,0),_loc3_);
  139.    blur_mc._visible = true;
  140.    bmp.jpg.attachBitmap(myBitmapData,2,"auto",true);
  141.    bmp.gotoAndPlay(2);
  142. }
  143. function win()
  144. {
  145.    resss.enabled = false;
  146.    show_blur();
  147.    cupedon.stop();
  148.    _root.score_menu._visible = true;
  149.    _root.score_menu.score_menu.gotoAndStop(1);
  150.    _root.score_menu.score_menu.score = level_score;
  151.    _root.score_menu.score_menu.compl.text = "Level " + _root.level + " Completed";
  152.    _root.total_score += level_score;
  153.    _root.score_menu.play();
  154.    gameplay = false;
  155.    paused = true;
  156. }
  157. function lose()
  158. {
  159.    show_blur();
  160.    cupedon.stop();
  161.    _root.score_menu._visible = true;
  162.    _root.score_menu.score_menu.gotoAndStop(2);
  163.    _root.score_menu.score_menu.hearts = hearts_req - hearts_beat;
  164.    _root.score_menu.play();
  165.    gameplay = false;
  166.    paused = true;
  167. }
  168. function oef()
  169. {
  170.    if(_root._fps < 55)
  171.    {
  172.       back._x -= 0.5;
  173.       if(back._x <= -920)
  174.       {
  175.          back._x = 0;
  176.       }
  177.    }
  178.    var _loc2_ = {x:cupedon.kupedon.hand._x,y:cupedon.kupedon.hand._y};
  179.    cupedon.kupedon.hand.localToGlobal(_loc2_);
  180.    if(!paused)
  181.    {
  182.       board.level = _root.level;
  183.       board.arrows = total_arrows;
  184.       board.score = total_score + level_score;
  185.       board.hearts = hearts_beat + "/" + hearts_req;
  186.       if(bullet._x <= -50 or bullet._x >= 750 or bullet._y >= 550)
  187.       {
  188.          if(!try_end() && !gameplay)
  189.          {
  190.             bullet._x = 400000;
  191.             bow_str._visible = true;
  192.             bow.gotoAndStop(1);
  193.             gameplay = true;
  194.             i = 0;
  195.             while(i < todel_objects.length)
  196.             {
  197.                stage_objects.splice(todel_objects[i],1);
  198.                i++;
  199.             }
  200.          }
  201.       }
  202.    }
  203.    if(!paused)
  204.    {
  205.       delta_x = bow._x - _xmouse;
  206.       delta_y = bow._y - _ymouse;
  207.       a = (- Math.atan2(delta_x,delta_y)) / 0.017453292519943295;
  208.       if(a < 0 && a > -180)
  209.       {
  210.          cupedon._xscale = 100;
  211.          bow._xscale = 100;
  212.          bow_hand._xscale = 100;
  213.          bow_hand2._xscale = 100;
  214.          bow_legs._xscale = 100;
  215.          bow_air._xscale = 100;
  216.          bow_str._xscale = 100;
  217.          bow._x = _loc2_.x + 5;
  218.          bow_air._x = bow._x + 6;
  219.       }
  220.       else
  221.       {
  222.          bow._x = _loc2_.x - 5;
  223.          bow_air._x = bow._x - 6;
  224.          cupedon._xscale = -100;
  225.          bow._xscale = -100;
  226.          bow_hand._xscale = -100;
  227.          bow_hand2._xscale = -100;
  228.          bow_legs._xscale = -100;
  229.          bow_air._xscale = -100;
  230.          bow_str._xscale = -100;
  231.       }
  232.       bow._rotation = a;
  233.       bow_hand._rotation = a;
  234.       bow._y = _loc2_.y + 23;
  235.       bow_air._y = bow._y + 14;
  236.       bow_hand._x = bow._x;
  237.       bow_hand._y = bow._y;
  238.       bow_legs._x = bow._x;
  239.       bow_legs._y = bow._y + 18;
  240.       delta_x = bow_str._x - _xmouse;
  241.       delta_y = bow_str._y - _ymouse;
  242.       a = (- Math.atan2(delta_x,delta_y)) / 0.017453292519943295;
  243.       bow_str._rotation = a;
  244.       bow_str._x = bow._x - (power - 15) / 2 * Math.sin(bow_str._rotation * 0.017453292519943295);
  245.       bow_str._y = bow._y + (power - 15) / 2 * Math.cos(bow_str._rotation * 0.017453292519943295);
  246.       bow_hand2._x = bow_str._x;
  247.       bow_hand2._y = bow_str._y;
  248.       if(a < 0 && a > -180)
  249.       {
  250.          delta_x = bow_hand2._x - bow._x + 20;
  251.          delta_y = bow_hand2._y - bow._y;
  252.          a = (- Math.atan2(delta_x,delta_y)) / 0.017453292519943295;
  253.          bow_hand2._rotation = - a;
  254.       }
  255.       else
  256.       {
  257.          delta_x = bow_hand2._x - bow._x - 20;
  258.          delta_y = bow_hand2._y - bow._y;
  259.          a = (- Math.atan2(delta_x,delta_y)) / 0.017453292519943295;
  260.          bow_hand2._rotation = - a;
  261.       }
  262.    }
  263. }
  264. function power_on()
  265. {
  266.    if(power_t == "up")
  267.    {
  268.       power += 2.5;
  269.    }
  270.    if(power_t == "down")
  271.    {
  272.       power -= 2.5;
  273.    }
  274.    if(power >= 50)
  275.    {
  276.       power_t = "down";
  277.    }
  278.    if(power < 15)
  279.    {
  280.       power_t = "up";
  281.    }
  282. }
  283. stop();
  284. _root.wl = "empty";
  285. if(_root.gamemode == "normal")
  286. {
  287.    hearts_req = 35;
  288.    total_arrows = 4;
  289. }
  290. else if(_root.gamemode == "hardcore")
  291. {
  292.    hearts_req = 56;
  293.    total_arrows = 4;
  294. }
  295. var colors_array = new Array("red","violet","blue","pink");
  296. delete onEnterFrame;
  297. delete mouseListener;
  298. clearInterval(oef_int);
  299. clearInterval(power_on_int);
  300. _root.createEmptyMovieClip("draw_mc",413);
  301. oef_int = setInterval(oef,42);
  302. _root._fps = 55;
  303. hearts_beat = 0;
  304. board.level = _root.level;
  305. board.arrows = total_arrows;
  306. board.score = total_score;
  307. board.hearts = hearts_beat + "/" + hearts_req;
  308. power_t = "up";
  309. power = 15;
  310. gameplay = true;
  311. gravity = 2;
  312. xgravity = 0;
  313. stoned = false;
  314. _root.boom_dp = 200;
  315. bullet._x = 100000;
  316. level_score = 0;
  317. paused = false;
  318. level_arrows = total_arrows;
  319. var tohit = new Array();
  320. var mouseListener = new Object();
  321. var boomSound = new Sound();
  322. _root.createEmptyMovieClip("blur_mc",400);
  323. i = 1;
  324. while(i <= 14)
  325. {
  326.    if(i > total_arrows)
  327.    {
  328.       board_arrows["a" + i]._visible = false;
  329.    }
  330.    i++;
  331. }
  332. resss.enabled = true;
  333. savings.data.score = _root.total_score;
  334. savings.data.level = _root.level;
  335. savings.data.gamemode = _root.gamemode;
  336. var myBitmapData = new flash.display.BitmapData(700,500,true,13421772);
  337. onEnterFrame = function()
  338. {
  339.    mseconds = getTimer() - timeStart;
  340.    draw_mc.moveTo(bullet._x,bullet._y);
  341.    bullet._x += bullet.vector.x;
  342.    bullet._y -= bullet.vector.y;
  343.    bullet.vector.x *= 0.9800000000000004;
  344.    bullet.vector.y *= 0.9800000000000004;
  345.    bullet.vector.y -= gravity;
  346.    bullet.vector.x -= xgravity;
  347.    if(gravity != 0)
  348.    {
  349.       bullet._rotation = Math.atan2(bullet.vector.x,bullet.vector.y) / 0.017453292519943295;
  350.    }
  351.    timeStart = getTimer();
  352.    _root._fps = mseconds;
  353. };
  354. mouseListener.onMouseDown = function()
  355. {
  356.    if(_root.tohit.length <= 0)
  357.    {
  358.       clearInterval(power_on_int);
  359.       if(gameplay)
  360.       {
  361.          power = 15.1;
  362.          power_on_int = setInterval(power_on,42);
  363.       }
  364.    }
  365. };
  366. mouseListener.onMouseUp = function()
  367. {
  368.    if(gameplay && power > 15)
  369.    {
  370.       _root.gravity = 2;
  371.       board_arrows["a" + level_arrows]._visible = false;
  372.       level_arrows--;
  373.       gameplay = false;
  374.       clearInterval(power_on_int);
  375.       bow_str._visible = false;
  376.       bow.gotoAndPlay(2);
  377.       bullet._x = bow._x + 40 * Math.sin(bow._rotation * 0.017453292519943295);
  378.       bullet._y = bow._y - 40 * Math.cos(bow._rotation * 0.017453292519943295);
  379.       bullet.vector = {x:power * Math.sin(bow._rotation * 0.017453292519943295),y:power * Math.cos(bow._rotation * 0.017453292519943295)};
  380.       power = 15;
  381.    }
  382. };
  383. Mouse.addListener(mouseListener);
  384.